package com.jerry.shop.mapper;

import com.jerry.shop.bean.Order;
import org.apache.ibatis.annotations.*;
import java.util.List;

//这是Order操作数据库的mapper
@Mapper
public interface OrderMapper {

    @Select("select * from t_order")
    public List<Order> getOrderList();

    @Select("select * from t_order where buyerId=#{buyerId}")
    List<Order> getOrderListByBuyerId(String buyerId);

    @Select("select * from t_order where id=#{id}")
    public Order getOrderById(String id);

    @Insert("insert into t_order(id, buyerId, buyerName, buyerPhone, buyerAddress, amount, status, payStatus) values(#{id}, #{buyerId}, #{buyerName}, #{buyerPhone}, #{buyerAddress}, #{amount}, #{status}, #{payStatus})")
    public int insertOrder(Order order);

    @Update("update t_order set buyerId=#{buyerId}, buyerName=#{buyerName}, buyerPhone=#{buyerPhone}, buyerAddress=#{buyerAddress}, amount=#{amount}, status=#{status}, payStatus=#{payStatus} where id=#{id}")
    public int updateOrder(Order order);

    @Delete("delete from t_order where id=#{id}")
    public int deleteOrderById(Integer id);

}
